package {
import flare.animate.TransitionEvent;
import flare.animate.Transitioner;
import flare.demos.Layouts;
import flare.display.LineSprite;

import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.text.TextField;

import mx.controls.Button;
import mx.rpc.soap.WebService;

[SWF(width="1000",height="700",backgroundColor="#ffffff", frameRate="30")]
public class Start extends Sprite
{
    private var _demoLayout:Layouts;
    private var _demo:Sprite;
    private var _line:LineSprite;
    private var _stageReplace:Stage

    public function Start(stageReplace:Stage)
    {
        _stageReplace = stageReplace;
        _stageReplace.scaleMode = StageScaleMode.NO_SCALE;
        _stageReplace.align = StageAlign.TOP_LEFT;
        _stageReplace.addEventListener(Event.RESIZE, onResize);

        showStartLayout()
        onResize();
    }


    private function showStartLayout():void
    {
        addChild(_line = new LineSprite());

        _demo = new Sprite();
        addChild(_demo);

        _demoLayout = new Layouts();
        _demo.alpha = 0;
        _demo.addChild(_demoLayout as Sprite);

        var t:Transitioner = new Transitioner(1);
        t = new Transitioner(1);
        t.delay = 0.5;
        t.addEventListener(TransitionEvent.START,
                function(evt:Event):void {
                    onResize();
                    _demoLayout.start();
                }
                );
        t.$(_demo).alpha = 1;
        t.play();
    }

    private function onResize(event:Event = null):void
    {
        _line.x2 = _stageReplace.stageWidth;
        _demoLayout.bounds = new Rectangle(0, _line.y,
                _stageReplace.stageWidth, _stageReplace.stageHeight - (_line.y));
    }
}
}